package com.oot2d.util;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;

public class InputManager {
    public static boolean[] keys;

    public static void init()
    {
        keys = new boolean[15];
    }

    public static void setKeys(GameContainer gc)
    {
        Input i = gc.getInput();

        keys[0] = i.isKeyDown(Input.KEY_A);
        keys[1] = i.isKeyDown(Input.KEY_D);
        keys[2] = i.isKeyDown(Input.KEY_W);
        keys[3] = i.isKeyDown(Input.KEY_S);
        keys[4] = i.isMousePressed(0);
        keys[5] = i.isMouseButtonDown(1);
        keys[6] = i.isKeyPressed(Input.KEY_TAB);
        keys[7] = i.isKeyPressed(Input.KEY_ESCAPE);
        keys[8] = i.isKeyPressed(Input.KEY_A);
        keys[9] = i.isKeyPressed(Input.KEY_D);
        keys[10] = i.isKeyPressed(Input.KEY_W);
        keys[11] = i.isKeyPressed(Input.KEY_S);
        keys[12] = i.isKeyPressed(Input.KEY_1);
        keys[13] = i.isKeyPressed(Input.KEY_2);
        keys[14] = i.isKeyPressed(Input.KEY_3);
    }

    public static void clearKeys()
    {
        for (int i = 0; i < keys.length; i++)
            keys[i] = false;
    }

    public static boolean left()
    {
        return keys[0];
    }

    public static boolean right()
    {
        return keys[1];
    }

    public static boolean up()
    {
        return keys[2];
    }

    public static boolean down()
    {
        return keys[3];
    }

    public static boolean mouse1()
    {
        return keys[4];
    }

    public static boolean mouse2()
    {
        return keys[5];
    }

    public static boolean tab()
    {
        return keys[6];
    }

    public static boolean esc()
    {
        return keys[7];
    }

    public static boolean leftTap()
    {
        return keys[8];
    }

    public static boolean rightTap()
    {
        return keys[9];
    }

    public static boolean upTap()
    {
        return keys[10];
    }

    public static boolean downTap()
    {
        return keys[11];
    }

    public static boolean cleft()
    {
        return keys[12];
    }

    public static boolean cdown()
    {
        return keys[13];
    }

    public static boolean cright()
    {
        return keys[14];
    }
}
